home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7492 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: newshost.cyberramp.net!news
  2. From: sinan@cyberramp.net (John Noland)
  3. Newsgroups: comp.os.msdos.programmer,comp.lang.asm.x86,comp.lang.c
  4. Subject: Re: Urg,ent, keyboard buffer overflow
  5. Date: 27 Feb 1996 00:17:54 GMT
  6. Organization: Prose Software
  7. Message-ID: <4gtiji$qn2@newshost.cyberramp.net>
  8. References: <Pine.SOL.3.91.960225103721.16366A-100000@hamlet.uncg.edu>
  9. NNTP-Posting-Host: ramp3-15.cyberramp.net
  10. X-Newsreader: WinVN 0.99.5
  11.  
  12. In article <Pine.SOL.3.91.960225103721.16366A-100000@hamlet.uncg.edu>, b_lee2@hamlet.uncg.edu says...
  13. >
  14. >
  15. >Hi, folks:
  16. >
  17. >I wrote a DOS program in Borland C++, because my interrupt service routine
  18. >block OS for 3 millisecond of every 5 millisecond, I think this cause 
  19. >bios no time to serve and check keyboard buffer, which cause keybord buffer
  20. >overflow.
  21. >
  22. >Two questions:
  23. >1. related to process of bios handler keyboard buffer, when IRQ1 generate 
  24. >a interrupt, but has not finished its ISR, can other IRQ, such as IRQ7 
  25. >generate a interrupt in between ? How can keyboard buffer overflow happen ?
  26. >
  27. >2. cli and sti will disable and enable all IRQ, is there a instruction which
  28. >will only disable and enable one specific IRQ, like IRQ7.
  29. >
  30. >structure of my program
  31. >
  32. >int main(void)
  33. >{
  34. >        InstallExternalTimingIRQ7ISR()
  35. >
  36. >        while( waitkey() )
  37. >        {
  38. >                doKeyboardInput_ScrOutout();
  39. >        }
  40. >        
  41. >        ReinstallOldIRQ7ISR();
  42. >}
  43. >My interrupt happens every 5 ms and program need 3 ms to finish its ISR,
  44. >during this time, I use cli and sti to protect its service, how will this 
  45. >affect keyboard interrupt ? The interrupt I used is external circuit 
  46. >generate 5 ms interrupt connect to IRQ7.
  47. >
  48. >Thanks folks, this is urgent for me, please send me a mail.
  49.  
  50. Hardware interrupts are first fielded by the PIC (Intel 8259A Progammable
  51. Interrupt Controller). This thing acts as a sort of receptionist for the
  52. CPU. It accepts up to eight distinct interrupts and can mask (ignore) 
  53. interrupts individually. It responds to each unmasked interrupt and 
  54. forwards it to the CPU, provided no other interrupt of higher priority
  55. is being serviced at that moment, Basically, the lower the IRQ number,
  56. the higher the priority.Timer - IRQ0, Keyboard - IRQ2, etc...
  57. To answer your question, you can mask individual interrupts on the PIC.
  58. This isn't the correct thing to do. The CPU automatically disables all
  59. interrupts when it transfers control to the service routine for the current
  60. interrupt. During the servicing of the interrupt, the PIC inhibits further
  61. interrupts of the same or lower priority, but higher priority interrupts
  62. are still acknowledged if the interrupt flag is set. To allow this to
  63. function correctly, your ISR *MUST* reenable interrupts with an STI
  64. immediately, before it begins servicing your interrupt.  This allows the
  65. other devices to function properly.
  66.  
  67.